package net.jielan188.hd.util.common;

import java.io.InputStream;

/**
 * request IO流处理工具
 *@author huangguogang
 *@date 2017-01-23
 */

public class IOUtils {

  public static String inputStreamToString( InputStream in, String encode ) {

    StringBuilder result = new StringBuilder();
    byte[] b = new byte[1024];
    int len1;
    try {
      while( -1 != ( len1 = in.read(b) ) ) {
        result.append( new String( b, 0, len1, encode ) );
      }
    } catch ( Exception e ) {
      e.printStackTrace();
      return "";
    }
    return result.toString();
  }

}